package com.appspot.etao.model;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.appspot.etao.util.StringUtil;
import com.taobao.top.domain.TaobaokeItem;

@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class TaobaokeItemModel extends BaseModel {
	
	private static final long serialVersionUID = 5873722631967414168L;

    @PrimaryKey
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
    private Long id;
    
    /** 淘宝客商品编号 */
    @Persistent
	private String iid;
    
    /** 商品所属类别 （本地封装属性）*/
    @Persistent
	private String cid;
    
    /** 宝贝名称 */
    @Persistent
	private String title;
    
    /** 卖家昵称 */
    @Persistent
	private String nick;
    
    /** 图片地址 */
    @Persistent
	private String picUrl;
    
    /** 商品价格 */
    @Persistent
	private String price;
    
    /** 推广点击网址 */
    @Persistent
	private String clickUrl;
    
    /** 淘宝客佣金 */
    @Persistent
	private String commission;
    
    /** 淘宝客佣金比率 */
    @Persistent
	private String commissionRate;
    
    /** 累计成交量 */
    @Persistent
	private String commissionNum;
    
    /** 累计总支出佣金量 */
    @Persistent
	private String commissionVolume;
    
    /** 淘宝客推广链接 */
    @Persistent
    private String promotionUrl;
    
    private TaobaokeItem taobaokeItem;
	
	public TaobaokeItemModel() {
		
	}
	public TaobaokeItemModel(TaobaokeItem taobaokeItem, String cid) {
		this.cid = cid;
		setTaobaokeItem(taobaokeItem);
	}
	
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getIid() {
		return iid;
	}

	public void setIid(String iid) {
		this.iid = iid;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getNick() {
		return nick;
	}

	public void setNick(String nick) {
		this.nick = nick;
	}

	public String getPicUrl() {
		return picUrl;
	}

	public void setPicUrl(String picUrl) {
		this.picUrl = picUrl;
	}

	public String getPrice() {
		return price;
	}

	public void setPrice(String price) {
		this.price = price;
	}

	public String getClickUrl() {
		return clickUrl;
	}

	public void setClickUrl(String clickUrl) {
		this.clickUrl = clickUrl;
	}

	public String getCommission() {
		return commission;
	}

	public void setCommission(String commission) {
		this.commission = commission;
	}

	public String getCommissionRate() {
		return commissionRate;
	}

	public void setCommissionRate(String commissionRate) {
		this.commissionRate = commissionRate;
	}

	public String getCommissionNum() {
		return commissionNum;
	}

	public void setCommissionNum(String commissionNum) {
		this.commissionNum = commissionNum;
	}

	public String getCommissionVolume() {
		return commissionVolume;
	}

	public void setCommissionVolume(String commissionVolume) {
		this.commissionVolume = commissionVolume;
	}

	public TaobaokeItem getTaobaokeItem() {
		return taobaokeItem;
	}

	public String getCid() {
		return cid;
	}
	public void setCid(String cid) {
		this.cid = cid;
	}
	
	public String getPromotionUrl() {
		return promotionUrl;
	}
	
	public void setPromotionUrl(String promotionUrl) {
		this.promotionUrl = promotionUrl;
	}
	
	public void setTaobaokeItem(TaobaokeItem taobaokeItem) {
		this.taobaokeItem = taobaokeItem;
		
		this.iid = StringUtil.cut(taobaokeItem.getIid());
		this.title = StringUtil.cut(taobaokeItem.getTitle());
		this.nick = StringUtil.cut(taobaokeItem.getNick());
		this.picUrl = taobaokeItem.getPicUrl();
		this.price = StringUtil.cut(taobaokeItem.getPrice());
		this.clickUrl = taobaokeItem.getClickUrl();
		this.commission = StringUtil.cut(taobaokeItem.getCommission());
		this.commissionNum = StringUtil.cut(taobaokeItem.getCommissionNum());
		this.commissionRate = StringUtil.cut(taobaokeItem.getCommissionRate());
		this.commissionVolume = StringUtil.cut(taobaokeItem.getCommissionVolume());
		this.promotionUrl = taobaokeItem.getPromotionUrl();
	}

	public String toString() {
		StringBuffer sb = new StringBuffer("");
		sb.append("[");
		sb.append(iid);
		sb.append(",");
		sb.append(title);
		sb.append(",");
		sb.append(nick);
		sb.append(",");
		sb.append(picUrl);
		sb.append(",");
		sb.append(price);
		sb.append(",");
		sb.append(clickUrl);
		sb.append(",");
		sb.append(commission);
		sb.append(",");
		sb.append(commissionNum);
		sb.append(",");
		sb.append(commissionRate);
		sb.append(",");
		sb.append(commissionVolume);
		sb.append("]");
		
		return sb.toString();
	}
}
